<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<meta charset="UTF-8" />
	<title>修改</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <link th:href="@{/static/css/right4.css}" rel="stylesheet">
    <!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    
<script type="text/javascript">
function check(form) {
    if(form.oldPassword.value=='') {
          alert("请输入旧密码!");
          form.oldPassword.focus();
          return false;
     }
 	if(form.password.value==''){
          alert("请输入新密码!");
          form.password.focus();
          return false;
    }
 	if(form.confirmspassword.value==''){
          alert("请输入确认密码!");
          form.confirmspassword.focus();
          return false;
    }
 	if(form.password.value != form.confirmspassword.value){
 		alert("新密码与确认密码不一致!");
 		form.newpassword.focus();
 		form.confirmspassword.focus();
 		return false;
 	}
   return ;
   }
</script>

<script type="text/javascript">
	$(function(){
		//checkIsExist();
		clearCss();
	})
	function checkIsExist() {  
			  var oldpassword = $.trim($("#oldpassword").val());  
			  $.ajax({  
			      type:"POST",   //http请求方式  
			      url:"/membership/ajax/teacherPassword/isExist", //发送给服务器的url  
			      data:"oldpassword="+oldpassword, //发送给服务器的参数  
			      dataType:"json",  //告诉JQUERY返回的数据格式(注意此处数据格式一定要与提交的controller返回的数据格式一致,不然不会调用回调函数complete)  
			      complete : function(msg) {  
			        var result = eval("(" + msg.responseText + ")");  
			        if(result.success) {  
			            $("#showResult").html(result.message);  
			          } else {  
			              $("#showResult").html(result.message);  
			          }   
			     }   
			  });
	 }  
	function clearCss() {  
		 $("#showResult").html("");    
    }
</script>
</head>
<body>

	<div class="container bg-white">
       <div class="row">
        <div class="col-md-8 col-md-offset-2  col-xs-8 col-xs-offset-2   col-lg-8 col-lg-offset-2 ">
             <br>
            <form class="form-horizontal" th:action="@{/membership/upPassword}" th:object="${membership}" method="post">
            	<input type="hidden" id="id" name="id" th:value="${membership.id}" />
            	<input type="hidden" id="uppassword" name="uppassword" th:value="${membership.password}" />
             <br>
             	<div style="border-left:#3399FF solid 2px; padding:10px;"><h4>修改会员密码</h4></div>
                <hr>
                 <div class="form-group">
                    <label for="" class="col-sm-3 control-label">原密码</label>
                    <div class="col-sm-7">
                    <input type="password" class="form-control" name="oldPassword" id="oldPassword"/>
                    <span id="showResult"></span>
                    </div>
                  </div>
                 <div class="form-group">
                    <label for="" class="col-sm-3 control-label">新密码</label>
                    <div class="col-sm-7">
                    	<input type="password" class="form-control" name="password" id="password"/>
                    </div>
                  </div>	
                 <div class="form-group">
                    <label for="" class="col-sm-3 control-label">确认密码</label>
                    <div class="col-sm-7">
                    	<input type="password" class="form-control" name="confirmspassword" id="confirmspassword"/>
                    </div>
                  </div>	
                <div class="form-group">    
                 <br>
                    <div class="col-sm-1 col-sm-offset-7 ">  
                    <button type="reset" class="btn btn-primary">取消</button>
                    </div>
                    <div class="col-sm-1 col-sm-offset-1 ">
                    <button type="submit" class="btn btn-primary" onclick="return check(this.form)">修改</button>
                    </div>
                </div>
              </form>    
       	</div>
       </div>      
	</div>
	<script th:src="@{/static/js/jquery-2.1.4.js}"></script>
</body>
</html>